<?php
namespace app\admin\controller;

use app\Basic;
use app\Logined;
use \think\facade\Db;

class Config extends Logined
{
    public function save()
    {
        $parm = $this->request->param();
        Db::name('config')->delete(true);
        foreach ($parm as $key => $value) {
            Db::name('config')->insert([
                'name' => $key,
                'value' => $value,
            ]);
        }
        return $this->success('保存成功！');
    }

    public function list()
    {
        $list = Db::name('config')->select()->toArray();
        $configs = [];
        foreach ($list as $key => $item) {
            $configs[$item['name']]=$item['value'];
        }
        return $this->success('请求成功！',[
//            '$list'=>$list,
            'configs'=>$configs,
        ]);
    }




}
